#include <iostream>

using std::cout;
using std::endl;

class Base
{
public:
    Base(long number = 0)
    : _number(number)
    {
        cout << "Base(long = 0)" << endl;
    }

    virtual
    void print()
    {
        cout << "Base::_number = " << _number << endl;
    }

    ~Base()
    {
        cout << "~Base()" << endl;
    }
/* private: */
protected:
    long _number;
};

class Derived
: public Base
{
public:
    Derived(long number1 = 0, long number2 = 0)
    : Base(number1)
    , _number(number2)
    {
        cout << "Derived(long = 0, long = 0)" << endl;
    }

    /* void print(); */

    virtual
    void print(int x)
    {
        cout << "形参x = " << x << endl;
        cout << "_number = " << this->_number << endl;
        cout << "吸收的_number = " << Base::_number << endl;
    }

    ~Derived()
    {
        cout << "~Derived()" << endl;
    }

private:
    long _number;

};

void test()
{
    Derived d(100, 200);
    /* d.Base::print(); */
    /* d.print();//error */
    d.print(7);//隐藏了基类中的同名函数print

}

int main(int argc, char **argv)
{
    test();
    return 0;
}

